package xw.qxypt.modules.baseinfo.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import xw.qxypt.common.utils.PageUtils;
import xw.qxypt.common.utils.Query;

import xw.qxypt.modules.baseinfo.dao.LhpCardDao;
import xw.qxypt.modules.baseinfo.entity.LhpCardEntity;
import xw.qxypt.modules.baseinfo.entity.LhpInstallationPointEntity;
import xw.qxypt.modules.baseinfo.service.LhpCardService;
import xw.qxypt.modules.baseinfo.service.LhpInstallationPointService;


@Service("lhpCardService")
public class LhpCardServiceImpl extends ServiceImpl<LhpCardDao, LhpCardEntity> implements LhpCardService {

    @Autowired
    private LhpInstallationPointService lhpInstallationPointService;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<LhpCardEntity> page = this.page(
                new Query<LhpCardEntity>().getPage(params),
                new QueryWrapper<LhpCardEntity>()
        );
        List<LhpCardEntity> cardList=page.getRecords();
        List<LhpInstallationPointEntity> pointList=lhpInstallationPointService.list();
        for(LhpCardEntity cardEntity:cardList){
            for(LhpInstallationPointEntity pointEntity:pointList){
                if(cardEntity.getPointId().equals(pointEntity.getId())){
                    cardEntity.setPointName(pointEntity.getPointName());
                }
            }
        }
        return new PageUtils(page);
    }

}
